<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>用户登陆</title>
	</head>
	
	<body>
			
		<div>
			<input type="hidden" name="id"  value="1001" />
			用户名：<input type="text" name="username" value="admmm" />
			<br/>
			密码：<input type="password" name="password" value="123456" />
			
			
			<input type="button" id="btn01" value="提交" >
		</div>
	</body>
	
	<!-- 军规：凡是路径 js css 请求 全部用绝对路径 webapp  -->
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.4.4.js" ></script>
	
	<script type="text/javascript">
	
		$(function(){
			
			$('#btn01').click(function(){
				$.ajax({
					'type':'post',
					'url':'${pageContext.request.contextPath}/central/user.do',
					'data':{
						'username':$('input[name="username"]').val(),
						'password':$('input[name="password"]').val(),
						'id':$('input[name="id"]').val(),
					},
					'dataType':'json',
					'success':function(jsonData){
						//console.log('请求成功....');
						
						/* console.log(jsonData.entity.id);
						console.log(jsonData.entity.username);
						console.log(jsonData.entity.password); */
						
						if(jsonData.code==200){
							window.location.href='${pageContext.request.contextPath}/success.jsp';
						}else if(jsonData.code==405){
							window.location.href='${pageContext.request.contextPath}/permission.jsp';
						}
					}
				});
			});
		});
	</script>

</html>